<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<input type="text"  id="shuru" value="" />
		<input type="button" class="dian"  value="1" />
		<input type="button" class="dian"  value="2" />
		<input type="button" class="dian"  value="3" />
		<input type="button" class="dian"  value="4" />
		<input type="button" class="dian"  value="5" />
		<input type="button" class="dian"  value="6" />
		<input type="button" class="dian"  value="7" />
		<input type="button" class="dian"  value="+" />
		<input type="button" class="dian"  value="-" />
		<input type="button" id="res" value="=" />
	</body>
	<script type="text/javascript">
		var shuru = document.getElementById("shuru");
		var res = document.getElementById("res");
		var dian = document.getElementsByClassName("dian");
		var str = "";
		
		for (var i=0;i<dian.length;i++) {
			dian[i].onclick= function(){
				str += this.value;
				shuru.value = str;
			}
		}
		
		res.onclick = function(){
			shuru.value = eval(str);
			str = shuru.value;
		}
		
		
		
	</script>
</html>
